﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace PeppeDotNet.SP2010.Html5Fields.Controls
{
    public class Html5NumberInputControl : Html5InputControl
    {
        public Html5NumberInputControl() : base("number") { }

        #region Properties
        public double? Max
        {
            get
            {
                string s = base.Attributes["max"];
                if (String.IsNullOrEmpty(s)) return null;
                return double.Parse(s, CultureInfo.InvariantCulture);
            }
            set
            {
                base.Attributes["max"] = value.ToString();
            }
        }

        public double? Min
        {
            get
            {
                string s = base.Attributes["min"];
                if (String.IsNullOrEmpty(s)) return null;
                return double.Parse(s, CultureInfo.InvariantCulture);
            }
            set
            {
                base.Attributes["min"] = value.ToString();
            }
        }

        public double Step
        {
            get
            {
                string s = base.Attributes["step"];
                if (s == null) return -1;
                return double.Parse(s, CultureInfo.InvariantCulture);
            }
            set
            {
                base.Attributes["step"] = value.ToString();
            }
        } 
        #endregion
    }
}
